﻿namespace UnityEditor
{
    using System;

    internal class VCMonitorPostprocess : AssetPostprocessor
    {
        private static void OnPostprocessAllAssets(string[] importedAssets, string[] deletedAssets, string[] movedAssets, string[] movedFromPath)
        {
            if (VCProvider.isActive && (importedAssets.Length > 0))
            {
                VCTask task = VCProvider.Status(importedAssets, false);
                task.Wait();
                VCAssetList assetList = task.assetList;
                VCAssetList list2 = new VCAssetList();
                VCAssetList assets = new VCAssetList();
                if (assetList != null)
                {
                    foreach (VCAsset asset in assetList)
                    {
                        if ((asset.state == VCAsset.States.Synced) && !asset.readOnly)
                        {
                            list2.Add(asset);
                        }
                        if ((asset.state == VCAsset.States.Local) && EditorUserSettings.AutomaticAdd)
                        {
                            assets.Add(asset);
                        }
                    }
                    if (assets.Count > 0)
                    {
                        VCProvider.Add(assets);
                        VCDatabase.Invalidate();
                    }
                }
            }
        }
    }
}

